<template>
	<view>
		<view style="text-align: center;">
			<image src="/static/notice.png" mode="widthFix" style="width: 100%"></image>
			<view style="font-weight: bold; font-size: 35rpx; color: #7AA2ED;">{{message}}</view>
		</view>
	</view>
</template>

<script>
	import * as api from '@/api/clerk'
	import storage from '@/utils/storage'
	import * as app from '@/utils/app'
	export default {
		data() {
			return {
				message: '',
				scene: {}
			};
		},
		onLoad(option) {
			this.scene = app.parseScene(option.scene)
		},
		onShow() {
			if (storage.get('authToken') == false) {
				uni.navigateTo({ url: '/pages/user/login' })
			} else {
				this.confirmPrize();
			}
		},
		methods: {
			confirmPrize: function () {
				api.confirmPrize({
					// 1 翻牌抽奖奖品，2 平台盲盒奖品
					type: this.scene.type ?? '',
					// 奖品 ID
					prizeId: this.scene.prizeId ?? ''
				}).then(res => {
					this.message = res.msg;
				}).catch(res => {
					this.message = res.errMsg;
				});
			}
		}
	}
</script>

<style>
</style>